<?php
$post = $_POST['in'];
?>
<html>
<head>
<title>BBCode Test</title>
<script type="text/javascript" src="BBCode.js"></script>
<script type="text/javascript">
function outputBBCode(textarea) {
	var editor = new DomBBCodeParser();
	document.getElementById('out').innerHTML = editor.parse(textarea.value);
}
var editor = new DomBBCodeEditor( 'in' );
</script>
</head>
<body>
	<div>
		<a class="button" href="javascript:editor.addTag('[b]','[/b]');"> B </a>
		<a class="button" href="javascript:editor.addTag('[u]','[/u]');"> U </a>
		<a class="button" href="javascript:editor.addTag('[i]','[/i]');"> I </a>
		<a class="button" href="javascript:editor.addUrl();"> URL </a>
		<a class="button" href="javascript:editor.addImage();"> IMAGE </a>
		<br>
		<a class="button" href="javascript:editor.addTag(':)');"> :) </a>
	</div>
	<textarea name="in" id="in" rows="12" cols="80">
	[b]bold[/b], [i]italic[/i], [u]underlined[/u], [s]strike-through[/s], [samp]sample[/samp] 
	[url]http://blogs.stonesteps.ca/showpost.asp?pid=33[/url]
	[url=http://blogs.stonesteps.ca/showpost.asp?pid=33][i]BBCode[/i] Parser[/url]
	Inline [q=http://blogs.stonesteps.ca/showpost.asp?pid=33]quote[/q]
	[blockquote=http://blogs.stonesteps.ca/showpost.asp?pid=33]Block quote[/blockquote][pre]formatted 
	     text[/pre][code]if(a == b) 
	   print("done");[/code]text containing [noparse] [brackets] [/noparse]
	c[b][color=red]o[/color][/b][b][color=green]l[/color][/b][b][color=blue]o[/color][/b]rs and [size=1.2]text size[/size]
	[b][i]mismatched [/b] tags[/i] 
	remaining text should not affect page HTML.
	</textarea>
	<div>
	<input type="submit" value="Submit" onclick="outputBBCode(document.getElementById(&quot;in&quot;))" style="vertical-align: top">
	</div>
	<div id="out"></div>
</body>
</html>